//|||||||||||||||||||||||||||||||||||||||||||||||

#include "GameProgress.hpp"
#include "GameApp.hpp"
#include <fstream>

using namespace std;

//|||||||||||||||||||||||||||||||||||||||||||||||

GameProgress::GameProgress() 
{
	for(int i = 0; i < NbGame1Easy; i++)
	{
		game1Easy[i] = NotDone;
	}
	for(int i = 0; i < NbGame1Medium; i++)
	{
		game1Medium[i] = NotDone;
	}
	for(int i = 0; i < NbGame1Hard; i++)
	{
		game1Hard[i] = NotDone;
	}
	for(int i = 0; i < NbGame2Easy; i++)
	{
		game2Easy[i] = NotDone;
	}
	for(int i = 0; i < NbGame2Medium; i++)
	{
		game2Medium[i] = NotDone;
	}
	for(int i = 0; i < NbGame2Hard; i++)
	{
		game2Hard[i] = NotDone;
	}
}

//|||||||||||||||||||||||||||||||||||||||||||||||

GameProgress::~GameProgress() 
{


}

//|||||||||||||||||||||||||||||||||||||||||||||||

void GameProgress::writeToFile(ofstream *stream)
{
	for(int i = 0; i < NbGame1Easy; i++)
	{
		(*stream) << game1Easy[i];
	}
	
	(*stream) << '\n'; 

	for(int i = 0; i < NbGame1Medium; i++)
	{
		(*stream) << game1Medium[i];
	}
	
	(*stream) << '\n'; 

	for(int i = 0; i < NbGame1Hard; i++)
	{
		(*stream) << game1Hard[i];
	}
	
	(*stream) << '\n'; 

	for(int i = 0; i < NbGame2Easy; i++)
	{
		(*stream) << game2Easy[i];
	}
	
	(*stream) << '\n'; 

	for(int i = 0; i < NbGame2Medium; i++)
	{
		(*stream) << game2Medium[i];
	}
	
	(*stream) << '\n'; 

	for(int i = 0; i < NbGame2Hard; i++)
	{
		(*stream) << game2Hard[i];
	}
}

//|||||||||||||||||||||||||||||||||||||||||||||||

void GameProgress::getFromFile(ifstream  *stream)
{
	char current;

	for(int i = 0; i < NbGame1Easy; i++)
	{
		(*stream) >> current;
		game1Easy[i] = (Achievement)(current -'0');
	}
	
	(*stream) >> current;

	for(int i = 0; i < NbGame1Medium; i++)
	{
		(*stream) >> current;
		game1Easy[i] = (Achievement)(current -'0');
	}
	
	(*stream) >> current;

	for(int i = 0; i < NbGame1Hard; i++)
	{
		(*stream) >> current;
		game1Easy[i] = (Achievement)(current -'0');
	}
	
	(*stream) >> current;

	for(int i = 0; i < NbGame2Easy; i++)
	{
		(*stream) >> current;
		game1Easy[i] = (Achievement)(current -'0');
	}
	
	(*stream) >> current;

	for(int i = 0; i < NbGame2Medium; i++)
	{
		(*stream) >> current;
		game1Easy[i] = (Achievement)(current -'0');
	}
	
	(*stream) >> current;

	for(int i = 0; i < NbGame2Hard; i++)
	{
		(*stream) >> current;
		game1Easy[i] = (Achievement)(current -'0');
	}
}